home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / SASC_6.0_Disk_4.adf / Compiler_Headers / Include / libraries / iffparse.h < prev    next >
C/C++ Source or Header  |  1992-07-30  |  6KB  |  205 lines

  1. #ifndef IFF_IFFPARSE_H
  2. #define IFF_IFFPARSE_H
  3. /*
  4. **    $Filename: libraries/iffparse.h $
  5. **    $Release: 2.04 Includes, V37.4 $
  6. **    $Revision: 33.1 $
  7. **    $Date: 90/11/20 $
  8. **
  9. **    Structure definitions for the all new good nifty IFF code.
  10. **
  11. **    (C) Copyright 1989-1991 Commodore-Amiga Inc., Stuart Ferguson, and
  12. **    Leo L. Schwab
  13. **        All Rights Reserved
  14. */
  15.  
  16. #ifndef EXEC_TYPES_H
  17. #include <exec/types.h>
  18. #endif
  19. #ifndef EXEC_LISTS_H
  20. #include <exec/lists.h>
  21. #endif
  22. #ifndef EXEC_PORTS_H
  23. #include <exec/ports.h>
  24. #endif
  25. #ifndef DEVICES_CLIPBOARD_H
  26. #include <devices/clipboard.h>
  27. #endif
  28.  
  29. /*
  30.  * Struct associated with an active IFF stream.
  31.  * "iff_Stream" is a value used by the client's read/write/seek functions -
  32.  * it will not be accessed by the library itself and can have any value
  33.  * (could even be a pointer or a BPTR).
  34.  */
  35. struct IFFHandle {
  36.     ULONG    iff_Stream;
  37.     ULONG    iff_Flags;
  38.     LONG    iff_Depth;    /*  Depth of context stack.  */
  39.     /*  There are private fields hiding here.  */
  40. };
  41.  
  42. /*
  43.  * Bit masks for "iff_Flags" field.
  44.  */
  45. #define IFFF_READ    0L            /* read mode - default */
  46. #define IFFF_WRITE    1L            /* write mode */
  47. #define IFFF_RWBITS    (IFFF_READ | IFFF_WRITE)    /* read/write bits */
  48. #define IFFF_FSEEK    (1L<<1)            /* forward seek only */
  49. #define IFFF_RSEEK    (1L<<2)            /* random seek */
  50. #define    IFFF_RESERVED    0xFFFF0000L        /* Don't touch these bits. */
  51.  
  52. /*
  53.  * When the library calls your stream handler, you'll be passed a pointer
  54.  * to this structure as the "message packet".
  55.  */
  56. struct IFFStreamCmd {
  57.     LONG    sc_Command;    /*  Operation to be performed (IFFCMD_)    */
  58.     APTR    sc_Buf;        /*  Pointer to data buffer        */
  59.     LONG    sc_NBytes;    /*  Number of bytes to be affected    */
  60. };
  61.  
  62. /*
  63.  * A node associated with a context on the iff_Stack.  Each node
  64.  * represents a chunk, the stack representing the current nesting
  65.  * of chunks in the open IFF file.  Each context node has associated
  66.  * local context items in the (private) LocalItems list.  The ID, type,
  67.  * size and scan values describe the chunk associated with this node.
  68.  */
  69. struct ContextNode {
  70.     struct MinNode    cn_Node;
  71.     LONG        cn_ID;
  72.     LONG        cn_Type;
  73.     LONG        cn_Size;    /*  Size of this chunk           */
  74.     LONG        cn_Scan;    /*  # of bytes read/written so far */
  75.     /*  There are private fields hiding here.  */
  76. };
  77.  
  78. /*
  79.  * Local context items live in the ContextNode's.  Each class is identified
  80.  * by its lci_Ident code and has a (private) purge vector for when the
  81.  * parent context node is popped.
  82.  */
  83. struct LocalContextItem {
  84.     struct MinNode    lci_Node;
  85.     ULONG        lci_ID,
  86.             lci_Type,
  87.             lci_Ident;
  88.     /*  There are private fields hiding here.  */
  89. };
  90.  
  91. /*
  92.  * StoredProperty: a local context item containing the data stored
  93.  * from a previously encountered property chunk.
  94.  */
  95. struct StoredProperty {
  96.     LONG    sp_Size;
  97.     UBYTE    *sp_Data;
  98. };
  99.  
  100. /*
  101.  * Collection Item: the actual node in the collection list at which
  102.  * client will look.  The next pointers cross context boundaries so
  103.  * that the complete list is accessable.
  104.  */
  105. struct CollectionItem {
  106.     struct CollectionItem    *ci_Next;
  107.     LONG            ci_Size;
  108.     UBYTE            *ci_Data;
  109. };
  110.  
  111. /*
  112.  * Structure returned by OpenClipboard().  You may do CMD_POSTs and such
  113.  * using this structure.  However, once you call OpenIFF(), you may not
  114.  * do any more of your own I/O to the clipboard until you call CloseIFF().
  115.  */
  116. struct ClipboardHandle {
  117.     struct IOClipReq    cbh_Req;
  118.     struct MsgPort        cbh_CBport;
  119.     struct MsgPort        cbh_SatisfyPort;
  120. };
  121.  
  122. /*
  123.  * IFF return codes.  Most functions return either zero for success or
  124.  * one of these codes.    The exceptions are the read/write functions which
  125.  * return positive values for number of bytes or records read or written,
  126.  * or a negative error code.  Some of these codes are not errors per sae,
  127.  * but valid conditions such as EOF or EOC (End of Chunk).
  128.  */
  129. #define    IFFERR_EOF        -1L    /*  Reached logical end of file    */
  130. #define IFFERR_EOC        -2L    /*  About to leave context    */
  131. #define    IFFERR_NOSCOPE        -3L    /*  No valid scope for property    */
  132. #define    IFFERR_NOMEM        -4L    /*  Internal memory alloc failed*/
  133. #define    IFFERR_READ        -5L    /*  Stream read error        */
  134. #define    IFFERR_WRITE        -6L    /*  Stream write error        */
  135. #define    IFFERR_SEEK        -7L    /*  Stream seek error        */
  136. #define    IFFERR_MANGLED        -8L    /*  Data in file is corrupt    */
  137. #define    IFFERR_SYNTAX        -9L    /*  IFF syntax error        */
  138. #define    IFFERR_NOTIFF        -10L    /*  Not an IFF file        */
  139. #define    IFFERR_NOHOOK        -11L    /*  No call-back hook provided    */
  140. #define IFF_RETURN2CLIENT    -12L    /*  Client handler normal return*/
  141.  
  142. #define    MAKE_ID(a,b,c,d)    \
  143.     ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  144.  
  145. /*
  146.  * Universal IFF identifiers.
  147.  */
  148. #define    ID_FORM            MAKE_ID('F','O','R','M')
  149. #define    ID_LIST            MAKE_ID('L','I','S','T')
  150. #define    ID_CAT            MAKE_ID('C','A','T',' ')
  151. #define    ID_PROP            MAKE_ID('P','R','O','P')
  152. #define    ID_NULL            MAKE_ID(' ',' ',' ',' ')
  153.  
  154. /*
  155.  * Ident codes for universally recognized local context items.
  156.  */
  157. #define IFFLCI_PROP        MAKE_ID('p','r','o','p')
  158. #define IFFLCI_COLLECTION    MAKE_ID('c','o','l','l')
  159. #define IFFLCI_ENTRYHANDLER    MAKE_ID('e','n','h','d')
  160. #define IFFLCI_EXITHANDLER    MAKE_ID('e','x','h','d')
  161.  
  162. /*
  163.  * Control modes for ParseIFF() function.
  164.  */
  165. #define IFFPARSE_SCAN        0L
  166. #define IFFPARSE_STEP        1L
  167. #define IFFPARSE_RAWSTEP    2L
  168.  
  169. /*
  170.  * Control modes for StoreLocalItem().
  171.  */
  172. #define IFFSLI_ROOT        1L    /*  Store in default context       */
  173. #define IFFSLI_TOP        2L    /*  Store in current context       */
  174. #define IFFSLI_PROP        3L    /*  Store in topmost FORM or LIST  */
  175.  
  176. /*
  177.  * "Flag" for writing functions.  If you pass this value in as a size
  178.  * to PushChunk() when writing a file, the parser will figure out the
  179.  * size of the chunk for you.  (Chunk sizes >= 2**31 are forbidden by the
  180.  * IFF specification, so this works.)
  181.  */
  182. #define    IFFSIZE_UNKNOWN        -1L
  183.  
  184. /*
  185.  * Possible call-back command values.  (Using 0 as the value for IFFCMD_INIT
  186.  * was, in retrospect, probably a bad idea.)
  187.  */
  188. #define    IFFCMD_INIT    0    /*  Prepare the stream for a session    */
  189. #define    IFFCMD_CLEANUP    1    /*  Terminate stream session        */
  190. #define    IFFCMD_READ    2    /*  Read bytes from stream        */
  191. #define    IFFCMD_WRITE    3    /*  Write bytes to stream        */
  192. #define    IFFCMD_SEEK    4    /*  Seek on stream            */
  193. #define    IFFCMD_ENTRY    5    /*  You just entered a new context    */
  194. #define    IFFCMD_EXIT    6    /*  You're about to leave a context    */
  195. #define    IFFCMD_PURGELCI    7    /*  Purge a LocalContextItem        */
  196.  
  197. /*  Backward compatibility.  Don't use these in new code.  */
  198. #define    IFFSCC_INIT    IFFCMD_INIT
  199. #define    IFFSCC_CLEANUP    IFFCMD_CLEANUP
  200. #define    IFFSCC_READ    IFFCMD_READ
  201. #define    IFFSCC_WRITE    IFFCMD_WRITE
  202. #define    IFFSCC_SEEK    IFFCMD_SEEK
  203.  
  204. #endif
  205.